class ApplicationController < ActionController::Base
  protect_from_forgery
  layout :set_layout

   def after_sign_in_path_for(resource_or_scope)
    if resource_or_scope.is_a?(Employee) && current_employee.is_admin
      admin_path
    else
      super
    end
  end

  def get_document

    if !current_client.nil?
     doc_id = ClientDocument.where("client_id = #{current_client.id}").collect(&:document_id)
      return Document.where("id in (?)",doc_id )#current_client.documents
    else
      return Document.all
    end 
  end


  private

  def set_layout
     if employee_signed_in?
        return 'employee'
     elsif client_signed_in?
        return 'client'
     else
        return 'application'
     end
  end 
end
